Skip to content

Comments

Fix: Invalid JSON on gc-stats (#1801)#4

Open
MitchLewis930 wants to merge 1 commit intopr_054_beforefrom
pr_054_after
Open

Fix: Invalid JSON on gc-stats (#1801)#4
MitchLewis930 wants to merge 1 commit intopr_054_beforefrom
pr_054_after

Conversation

@MitchLewis930
Copy link

@MitchLewis930 MitchLewis930 commented Jan 30, 2026

PR_054


Note

Low Risk
Small change limited to /gc-stats JSON serialization and its test; low likelihood of side effects outside the control endpoint response format.

Overview
Fixes the /gc-stats control endpoint to emit proper JSON by switching from manual string construction to GC.stat.to_json (and requiring json).

Updates the CLI control tests to parse the response with JSON.parse (adding a json require) instead of a regex-based parser, ensuring the endpoint stays valid JSON.

Written by Cursor Bugbot for commit 2db1ef1. This will update automatically on new commits. Configure here.

* Fix: Invalid JSON on gc-stats

Credits of this patch should be for @jdsundberg, who reported the issue
but never sent a patch. Link to his bug report is below.

Closes puma#1687.

* Update tests so JSON response is correctly parsed

JSON without a whitespace between key and values wasn't being correctly
parsed (for example: `key: 'value'` was processed ok, but `key:'value'`
wasn't).
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


lines = body.split("\r\n")
json_line = lines.detect { |l| l[0] == "{" }
pairs = json_line.scan(/\"[^\"]+\": [^,]+/)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent JSON parsing - first gc-stats call not updated

Low Severity

The control_gc_stats method parses the /gc-stats JSON response twice: once for gc_count_before and once for gc_count_after. The PR only updated the second parsing to use JSON.parse (line 199), while the first parsing (lines 179-184) still uses the old regex-based approach. This creates an inconsistency within the same method - both instances parse the same JSON format but use different parsing methods.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants